package org.leo.study.gateway.route;

import org.springframework.cloud.gateway.route.RouteLocator;
import org.springframework.cloud.gateway.route.builder.RouteLocatorBuilder;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * <p>
 * 网关路由
 * </p>
 *
 * @Package: org.leo.study.gateway.route
 * @ClassName: GatewayRoutes
 * @author: Li.Junlin
 * @date: 2019.10.14 10:23
 */
//@Configuration
public class GatewayRoutes {

    @Bean
    public RouteLocator myRoutes(RouteLocatorBuilder builder) {
        return builder.routes()
                .route(p -> p.path("/get")
                        .filters(f -> f.addRequestHeader("Hello", "World"))
                        .uri("http://httpbin.org:80"))
//                .route(p -> p
//                        .host("*.hystrix.com")
//                        .filters(f -> f.hystrix(config -> config
//                                .setName("mycmd")
//                                .setFallbackUri("forward:/www.baidu.com")))
//                        .uri("http://httpbin.org:80"))80
                .build();
    }

}
